package mapper;

import DO.WorkTestTwoDataDO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface WorkTestTwoDataMapper {


    // 保存学生已经上传的数据
    @Insert("insert into work_test_two_data (user_id, work_id, `order`, address) values (#{userId},#{workId},#{order},#{address})")
    void save(WorkTestTwoDataDO workTestTwoDataDO);

    @Insert("insert into work_test_two_data (user_id, work_id, `order`, address,score) values (#{userId},#{workId},#{order},#{address},#{score})")
    void save1(WorkTestTwoDataDO workTestTwoDataDO);

    @Update("update work_test_two_data set address = #{address} where user_id = #{userId} and work_id = #{workId} and `order` = #{order}")
    Integer updateByOrder(WorkTestTwoDataDO workTestTwoDataDO);


    @Select("select * from work_test_two_data where user_id = #{userId} and work_id = #{workId} order by `order`")
    List<WorkTestTwoDataDO> getById(Integer workId, Integer userId);

    @Select("select address from work_test_two_data where user_id = #{userId} and work_id = #{workId} and `order` = #{order}")
    String getAddress(Integer userId, Integer workId, Integer order);

    @Update("update work_test_two_data set score = #{score} where work_id = #{workId} and user_id = #{userId} and `order` = #{k}")
    Integer uptateScore(int k,Double score, Integer workId, Integer userId);

    @Select("select score from work_test_two_data where user_id = #{userId} and work_id = #{workId} order by `order`")
    List<Double> getScores(Integer userId, Integer workId);

    @Select("select score from work_test_two_data where user_id = #{userId} and work_id = #{workId} and `order` = #{order}")
    Integer getScoresByOrder(Integer userId, Integer workId, Integer order);
}
